package com.infore.exchange.main.dao;

import com.infore.common.model.dto.exchange.JobTaskInfoQuartz;
import com.infore.common.model.entity.exchange.TJobTaskInfo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.infore.common.model.entity.exchange.TTaskInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 作业任务关联表 Mapper 接口
 * </p>
 *
 * @author lijh
 * @since 2023-02-13
 */
@Mapper
@Component
public interface TJobTaskInfoMapper extends BaseMapper<TJobTaskInfo> {







    @Select("<script>" +
            "select tjti.job_id,tti.task_id,tji.bean_name ,tji.method_name,tji.cron_schedule,tti.transform_params,tti.task_type from t_ex_job_task_info tjti \n" +
            "inner join t_ex_job_info tji on tjti.job_id = tji.job_id\n" +
            "inner join t_ex_task_info tti on tjti.task_id = tti.task_id\n" +
            "where 1=1 " +
            " <if test='jobId != null and jobId != \"\"'> "+
            "  and tjti.job_id=#{jobId} " +
            " </if> " +
            " <if test='jobState != null'> "+
            "  and tji.job_state=#{jobState} " +
            " </if> " +
            " <if test='taskState != null '> "+
            "  and tti.task_state=#{taskState} " +
            " </if> " +
            " <if test='runningState != null '> "+
            "  and tti.running_state=#{runningState} " +
            " </if> " +
            "</script>")
    List<JobTaskInfoQuartz> queryJobTaskInfoQuartzByJobId( @Param("jobId")  String jobId,@Param("jobState")  Integer jobState,@Param("taskState")  Integer taskState,@Param("runningState")  Integer runningState);





    @Select("<script>" +
            "select tti.* from t_ex_job_task_info tjti \n" +
            "inner join t_ex_task_info tti on tjti.task_id = tti.task_id\n" +
            "where 1=1" +
            " <if test='jobId != null and jobId != \"\"'> "+
            "  and tjti.job_id=#{jobId} " +
            " </if> " +
            " <if test='taskState != null '> "+
            "  and tti.task_state=#{taskState} " +
            " </if> " +
            "</script>")
    List<TTaskInfo> queryTaskInfoByJobId(@Param("jobId")  String jobId,@Param("taskState")  Integer taskState);
}
